package edu.hawaii.senin.iclouds.util;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

/**
 * Tests text utilities used in the project.
 * 
 * @author Pavel Senin.
 * 
 */
public class TestTextUtils {

  private static final String leadingSpaces = "   test";
  private static final String endingSpaces = "test   ";
  private static final String surroundingSpaces = "    test   ";
  private static final String endingNewLine = "    test   \n";
  private static final String someTabs = " \t \t   test   \n";
  private static final String asserter = "test";

  /**
   * Sets up testing environment.
   * 
   * @throws Exception if unable to set it up.
   */
  @Before
  public void setUp() throws Exception {
  }

  /**
   * Tests the chomp() method.
   * 
   */
  @Test
  public void testChomp() {
    assertEquals(asserter, TextUtils.chomp(leadingSpaces));
    assertEquals(asserter, TextUtils.chomp(endingSpaces));
    assertEquals(asserter, TextUtils.chomp(surroundingSpaces));
    assertEquals(asserter, TextUtils.chomp(endingNewLine));
    assertEquals(asserter, TextUtils.chomp(someTabs));
  }
}
